App.CheckBoxGrid=function(g){
	 var orderTypeD = Ext.data.Record.create([
           {
			name : 'line_id'
		},{
		    name: 'productdate'
		}, {
			name : 'request_date'
		}, {
			name : 'schedule_ship_date'
		}, {
			name : 'schedule_arrival_date'
		},{
			name : 'goodsid'
		}, {
			name : 'goodsno'
		}, {
			name : 'goodsname'
		}, {
			name : 'spec'
		}, {
			name : 'sale_price'
		}, {
			name : 'order_quantity_uom'
		}, {
			name : 'flow_status_code'
		}, {
			name : 'attrib1'
		}, {
			name : 'attrib1_unit'
		}, {
			name : 'attrib2'
		}, {
			name : 'attrib2_unit'
		}, {
			name : 'attrib3'
		}, {
			name : 'attrib3_unit'
		}, {
			name : 'attrib4'
		}, {
			name : 'attrib4_unit'
		}, {
			name : 'attrib5'
		}, {
			name : 'attrib5_unit'
		}	   
      ]);
	var search = function(){
		var searchName = Ext.getDom('searchName').value;	
		store.baseParams = {
			keywords : searchName,
			trancode : '13121'
		};
		store.load({
			params : {
				start : 0,
				limit : 10
			}
		});
	}
	var sm = new Ext.grid.CheckboxSelectionModel({handleMouseDown: Ext.emptyFn,singleSelect : true});
    var cm = new Ext.grid.ColumnModel([
		sm,{
			header:'产品ID',
			dataIndex:'goodsid',
			width:80
		},{
			header: "产品编码",
			dataIndex: 'goodsno',
			width:80
        },{
			header:'产品名称',
			dataIndex:'goodsname',
			width:180				
		},{
			header:'产品规格',
			dataIndex:'spec',
			width:80				
		}
    ]);
    cm.defaultSortable = true;
    var SaleArea = Ext.data.Record.create([
           {name: 'goodsid'},
           {name: 'goodsno'},
           {name: 'goodsname'},
           {name: 'spec'}
      ]);
	var store = new Ext.data.JsonStore({
		url:'../'+WebServiceUrl,
		baseParams:{trancode:'13120'},
		totalProperty:'totalProperty',
		root:'root',
		fields:SaleArea,
		pruneModifiedRecords:true
	});
	var grid = new Ext.grid.GridPanel({
    	id : 'BaseGrid',
        store: store,
        cm: cm,
        resizeable:true,
        height:230,
        width:500,
        frame:true,
		sm:sm,
		loadMask: {msg:'正在加载数据，请稍候。。。'},
		stripeRows:true,
		tbar : ['产品名称：', {
				xtype : 'trigger',
				id : 'searchName',
				width : 200,
				triggerClass : 'x-form-search-trigger',
				onTriggerClick : search
		}],
	    bbar: new Ext.PagingToolbar({
	        pageSize: 10,
	        store: store,
	        displayInfo: true,
	        displayMsg: '显示第 {0} 条到 {1} 条记录，一共 {2} 条',
	        emptyMsg: "没有记录"
	    })
    });
    grid.on('rowclick', function(grid, t) {
		if (sm.isSelected(t))
			sm.deselectRow(t);
		else
			sm.selectRow(t, true);
	});
	
    store.load({params:{start:0,limit:10}});
    var win = new Ext.Window({
    	id:'SelGrid',
		title : '产品选择',
		width : 500,
		height : 300,
		closable : false,
		collapsible : false,
		modal : true,
		defaults : {
			border : false
		},
		buttonAlign : 'right',
		items :grid,
		buttons :[{
			text:'确定',
			handler : function(){
				var _record = grid.getSelectionModel().getSelected();
				if (!_record) {
					Ext.MessageBox.alert('警告', '请选择一条信息!');
				} else {
						var m = new orderTypeD({
						productdate:9,
						request_date:new Date().clearTime(),
						schedule_ship_date:new Date().clearTime(),
						schedule_arrival_date:new Date().clearTime(),
						goodsid:_record.get('goodsid'),
						goodsname:_record.get('goodsname'),
						spec:_record.get('spec'),
						sale_price:'0',
						order_quantity_uom:'0',
						flow_status_code:'0',//工作流状态代码0：销售不可变更
						attrib1:0,
						attrib1_unit:'mm',
						attrib2:0,
						attrib2_unit:'mm',
						attrib3:0,
						attrib3_unit:'mm',
						attrib4:0,
						attrib4_unit:'mm',
						attrib5:0,
						attrib5_unit:'mm'						
					});
					var BaseGrid = g;
					var BaseStore = BaseGrid.getStore();
					BaseGrid.stopEditing();
					BaseStore.insert(0,m);
					BaseGrid.startEditing(0, 1);
					BaseStore.getAt(0).dirty=true;	
					BaseStore.commitChanges();
					win.close();
				}
			}
		},{
			text:'关闭',
			handler : function(){
				Ext.getCmp('SelGrid').close();
			}
		}]
    })    
    win.show();
    //注册回车查询事件
	Ext.getCmp('searchName').on('specialkey',search);
}